import request from '@/config/axios'
import type {Dayjs} from 'dayjs';

/** 工作流程信息 */
export interface WorkflowInfo {
    id: number; // ID
    module: string; // 模块
    taskId?: number; // 任务id
    flowName?: string; // 流程名称
    flowKey?: string; // 流程key
    state: string; // 流程状态
    aging: number; // 时效
    startTime: string | Dayjs; // 开始时间
    endTime: string | Dayjs; // 结束时间
    userId: string; // 执行人
    outTrackId: string; // 卡片实例id
    remark: string; // 备注
}

// 工作流程 API
export const WorkflowInfoApi = {
    // 查询工作流程分页
    getWorkflowInfoPage: async (params: any) => {
        return await request.get({url: `/general/workflow-info/page`, params})
    },
    //获取积分
    getMyUnFinishFlowNumber: async () => {
        return await request.get({url: `/general/workflow-info/getMyUnFinishFlowNumber`})
    },
    // 查询工作流程详情
    getWorkflowInfo: async (id: number) => {
        return await request.get({url: `/general/workflow-info/get?id=` + id})
    },

    // 新增工作流程
    createWorkflowInfo: async (data: WorkflowInfo) => {
        return await request.post({url: `/general/workflow-info/create`, data})
    },

    // 修改工作流程
    updateWorkflowInfo: async (data: WorkflowInfo) => {
        return await request.put({url: `/general/workflow-info/update`, data})
    },

    // 删除工作流程
    deleteWorkflowInfo: async (id: number) => {
        return await request.delete({url: `/general/workflow-info/delete?id=` + id})
    },

    /** 批量删除工作流程 */
    deleteWorkflowInfoList: async (ids: number[]) => {
        return await request.delete({url: `/general/workflow-info/delete-list?ids=${ids.join(',')}`})
    },

    // 导出工作流程 Excel
    exportWorkflowInfo: async (params) => {
        return await request.download({url: `/general/workflow-info/export-excel`, params})
    }


}
